<template>
    <div>
         <h3>{{viewData.viewTitle}}</h3>
        <div ref="treeCharts" class="fl echarts" :style="{width:'100%',height:viewData.viewHeight}"></div>
    </div>
</template>
<script>
import echarts from "echarts"
import {queryApi, fileUpload, fileUploadvideo} from '@/api/api'
export default {
    props:{
        viewData:{
            viewTitle:"",
            viewHeight:"",
            seiveApi:'',//接口方法
            serachParam:{},
            options:{
                series:[]
            }
        }
    },
    data() {
        return {

        };
    },
    methods: {
        init(){
            var echartsNew = this.$echarts.init(this.$refs.treeCharts);
            var seriesData = []
            if(this.viewData.seiveApi!=""){
                queryApi(this.viewData.serachParam).then(res => {
                    var json = res.data;
                    if(json.code == '000000'){
                        seriesData = json.series;
                    }
                })
            }else{
                seriesData = this.viewData.options.series;
            }
            var options = {
                    tooltip: {
                        trigger: 'item',
                        triggerOn: 'mousemove'
                    },
                    series:seriesData
                }
            echartsNew.setOption(options,true);
        }
    },
    mounted(){
        this.init();
    }
}
</script>